<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        li {
            list-style-type: none;
        }

        .topic-content {
            width: 60vw;
            margin: auto;
            border: 1px solid #000;
        }

        .topic-content .nav,
        .topic-content .content {
            display: flex;
        }

        .topic-content .nav li {
            width: calc(100% / 6);
            border: 1px solid #000;
            text-align: center;
        }

        .topic-content .content li {
            width: 100%;
            display: none;
            text-align: center;
            height: 200px;
            line-height: 200px;
        }

        .active {
            background: deeppink;
        }

        .show {
            display: block !important;
        }
    </style>
</head>

<body>
    <div class="topic-content">
        <!-- nav导航 -->
        <ul class="nav">
            <li class="active">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
        </ul>
        <!-- content内容 -->
        <ol class="content">
            <li class="show">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
        </ol>
    </div>
    <!-- <img src="./Snipaste_2022-08-16_17-59-42.png" alt=""> -->
    <script>
        let navList = document.querySelectorAll('.topic-content>.nav>li');//数组
        let contentList = document.querySelectorAll('.topic-content>.content>li');//都是数组
        for (let i = 0; i < navList.length; i++) {
            const nav = navList[i];
            nav.addEventListener('click', function () {
                for (let k = 0; k < navList.length; k++) {
                    const navSibling = navList[k];
                    navSibling.className = ''
                    contentList[k].className = ''
                }
                this.className = 'active'
                contentList[i].className = 'show'
            })
        }
    </script>
</body>

</html>